package com.yq.web;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yq.entity.Shequ;
import com.yq.service.ShequService;
import com.yq.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.text.html.parser.Entity;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author IceZhang
 * @since 2020-02-15
 */
@RestController
@RequestMapping("/shequ")
public class ShequController {
    @Autowired
    private ShequService shequService;

    @RequestMapping("/list")
    public R selectCategoryPage(Integer current, Integer size){
        Page<Shequ> equipmentCategoryPage = shequService.selectEquipmentCategoryPage(current, size);
        return R.ok().put("data",equipmentCategoryPage);
    }

    @RequestMapping("/insert")
    public R insertShequ(@RequestBody Shequ shequ){
        boolean insert = shequService.insert(shequ);
        if(insert) return R.ok();
        return R.error();
    }

    @RequestMapping("/del")
    public R deleteShequ(@RequestBody Shequ shequ){
        EntityWrapper<Shequ> shequEntityWrapper = new EntityWrapper<>();
        shequEntityWrapper.eq("code", shequ.getCode());

        boolean insert = shequService.delete(shequEntityWrapper);
        if(insert) return R.ok();
        return R.error();
    }


}

